package com.hongawen.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * @author hongawen
 * @version 1.0.0
 * @date 2021年08月16日 11:54
 */
public class TestDynamic {

    public static void main(String[] args) {
        DynamicBean dynamicBean = new DynamicBean();
        InvocationHandler handler = dynamicBean.getInvocationHandler();
        Spring spring = (Spring) Proxy.newProxyInstance(Spring.class.getClassLoader(),new Class[]{Spring.class},handler);
        Summer summer = (Summer) Proxy.newProxyInstance(Summer.class.getClassLoader(),new Class[]{Summer.class},handler);

        spring.springHello("hongawen");
        spring.hello("hongawen");

        summer.summerHello("summerhongawen");
        summer.hello("summerhongawen");
    }

}
